/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package socof_webcrawler;

public class Laucher extends Thread {

    private static Laucher lb = new Laucher();
    private LaunchDownloaders downloadersLauncher;
    private LaunchParsers parsersLauncher;

    private Laucher() {
        this.downloadersLauncher = LaunchDownloaders.getInstance();
        this.parsersLauncher = LaunchParsers.getInstance();
    }

    public static Laucher getInstance() {
        return Laucher.lb;
    }

    public void setMaxBandwithAllocation(long maxBandwithAllocation) {
        this.downloadersLauncher.setMaxBandwidthAllocation(maxBandwithAllocation);
    }

    public void setMaxCpuUsage(double maxCpuUsage) {
        this.parsersLauncher.setMaxCpuUsage(maxCpuUsage);
    }

    public void setDownloadersLimit(int downloadersLimit) {
        this.downloadersLauncher.setDownloadersLimit(downloadersLimit);
    }

    public void setParsersLimit(int parsersLimit) {
        this.parsersLauncher.setParsersLimit(parsersLimit);
    }

    @Override
    public void run() {
        try {

            this.downloadersLauncher.start();
            this.parsersLauncher.start();

            this.downloadersLauncher.join();
            this.parsersLauncher.join();

        } catch (InterruptedException ex) {
            this.downloadersLauncher.interrupt();
            this.parsersLauncher.interrupt();
        }
    }
}
